from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
import datetime,uuid
import django.utils.timezone as timezone

from welink.models import * 

#一次交友活动
class Party(models.Model):
    deleted = models.BooleanField('删除',default=False)
    name = models.CharField('名称',max_length=100)
    add_time = models.DateTimeField('创建时间', auto_now_add=True, blank=True)
    open_time = models.DateTimeField('开盒时间', null =True, blank=True)
    persons = models.ManyToManyField('welink.UserProfile',verbose_name= '参与者',through='JoinParty')


class JoinParty(models.Model):
    userprofile = models.ForeignKey('welink.UserProfile', on_delete=models.CASCADE)
    party = models.ForeignKey(Party, on_delete=models.CASCADE)
    join_time = models.DateTimeField('参加时间', auto_now_add=True, blank=True)        # 进组时间
    class Meta:
        unique_together = (
            ('userprofile','party'),  # 联合唯一
        )



# Create your models here.
